import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' // 如果是 Vue 项目
import federation from '@originjs/vite-plugin-federation'

export default defineConfig({
  plugins: [
    vue(),
    federation({
      name: 'base',
      filename: 'remoteEntry.js',
      exposes: {
        './Button': './src/components/Button.vue',
        './utils': './src/utils/index.js',
        "./action": "./src/action/index.js",
        "./store": "./src/store/index.js"
      },
      shared: {
        vue: {
          singleton: true,
          eager: true,
          requiredVersion: "^3.2.45"
        },
        pinia: {
          singleton: true,
          requiredVersion: "^2.2.6"
        },
        mitt: {
          singleton: true,
          requiredVersion: "^3.0.1"
        }
      }
    })
  ],
  server: {
    port: 3000,
    host: '0.0.0.0',
    open: true,
    cors: true,
    fs: {
      strict: true
    },
    headers: {
      'Access-Control-Allow-Origin': '*',
			'Access-Control-Allow-Headers': '*',
			'Access-Control-Allow-Methods': '*'
    }
  },
  build: {
    target: 'esnext',
    minify: false,
    cssCodeSplit: false,
    rollupOptions: {
      output: {
        minifyInternalExports: false
      }
    }
  },
  resolve:{
    alias: {
      "@": "/src"
    }
  }
})